﻿namespace John
{

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.SqlClient;


    public partial class viste_visteInfoChange : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //权限检查
            if (!IsPostBack)
            {
                //HttpCookie cookie = Request.Cookies["jisuanji110"];
                var session = Session["name"];
                if (session == null)
                {
                    Response.Redirect("~/login.aspx");
                    return;
                }
                this.user();
            }
        }
        protected void btnOK_Click(object sender, EventArgs e)
        {
            this.update();
        }

        private void user()
        {
            DBConn myDB = new DBConn();
            string sql = "select * from muser where hyname='" + Request.Cookies["jisuanji110"].Value + "'";
            SqlDataReader dr = myDB.getDataReader(sql);
            if (dr.Read())
            {
                TextBox1.Text = dr["gsname"].ToString();
                TextBox2.Text = dr["adreess"].ToString();
                TextBox3.Text = dr["youbian"].ToString();
                TextBox4.Text = dr["zsname"].ToString();
                TextBox5.Text = dr["shouji"].ToString();
                TextBox6.Text = dr["guding"].ToString();
                TextBox9.Text = dr["qq"].ToString();
                TextBox7.Text = dr["email"].ToString();
                TextBox8.Text = dr["http"].ToString();
            }
            dr.Close();
            myDB.Close();
        }

        private void update()
        {
            string sql = "update muser set gsname='" + TextBox1.Text + "',adreess='" + TextBox2.Text + "',youbian='" + TextBox3.Text +
                      "',zsname='" + TextBox4.Text + "',shouji='" + TextBox5.Text + "',guding='" + TextBox6.Text +
                      "',qq='" + TextBox9.Text + "',email='" + TextBox7.Text + "',http='" + TextBox8.Text + "' where hyname='" + Request.Cookies["jisuanji110"].Value + "'";

            DBConn myDB = new DBConn();
            myDB.Update(sql);
            myDB.Close();
        }
    }
}